package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.lis.entity.WkEmployee;
import com.ysd.lis.mapper.WkEmployeeMapper;
import com.ysd.lis.service.WkEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 科室办公 档案表 服务实现类
 * </p>
 *
 * @author LiuQi
 * @since 2024-02-19
 */
@Service
public class WkEmployeeServiceImpl extends ServiceImpl<WkEmployeeMapper, WkEmployee> implements WkEmployeeService {

    @Autowired
    WkEmployeeMapper wkEmployeeMapper;

    @Override
    public Result getEmployeeList() {
        LambdaQueryWrapper<WkEmployee> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(WkEmployee::getDelFlag, 0);
        List<WkEmployee> wkEmployees = wkEmployeeMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1, "查询成功！", wkEmployees);
    }

    @Override
    public Result addEmployee(WkEmployee wkEmployee) {
        boolean save = this.save(wkEmployee);
        if (save) {
            return Result.succ(1, "添加成功", null);
        } else {
            return Result.fail("添加失败");
        }
    }

    @Override
    public Result updateEmployee(WkEmployee wkEmployee) {
        boolean save = this.updateById(wkEmployee);
        if (save) {
            return Result.succ(1, "编辑成功", null);
        } else {
            return Result.fail("编辑失败");
        }
    }

    @Override
    public Result deleteEmployee(WkEmployee wkEmployee) {
        boolean b = this.removeById(wkEmployee.getId());
        if (b) {
            return Result.succ(1, "删除成功", null);
        } else {
            return Result.fail("删除失败");
        }
    }
}
